import { createRouter, createWebHistory } from "vue-router";
import store from "../store/index.js";

const routes = [
  {
    path: "/start",
    component: () => import("../view/start/index.vue"),
    children: [
      {
        path: "result",
        component: () => import("../view/result/index.vue"),
      },
      {
        path: "detail",
        component: () => import("../view/result/components/result.vue"),
      },
      {
        path: "login",
        component: () => import("../view/start/components/Login.vue"),
      },
      {
        path: "other",
        component: () => import("../view/other/index.vue"),
      },
    ],
  },
  {
    path: "/test",
    component: () => import("../view/test/index.vue"),
  },
  {
    path: "/",
    redirect: "/start/login",
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

// router.beforeEach((to, from, next) => {
//   if (to.path === "/result" && !store.state.enteredTest) {
//     next("/start");
//   } else {
//     next();
//   }
// });

export default router;
